<table border="0" align="right" class="products">
<?php 
	$count = count($products)-1;
	for ($i = 0; $i <= $count; $i++):
		if (($i-1) != 0 && ($i == 0 || $i % 3 == 0)): 
?> 
		<tr align="center" valign="top">
<?php endif;?>
			<td>
<?php $file_path = glob(STATICROOT."images/models/{$products[$i]['id']}_*.*", GLOB_BRACE);  $path = basename($file_path[0]); ?>	
				<a title="<?=$products[$i]['category_id']?>:&nbsp;<?=$products[$i]['ru_name']?>" href="<?=SCRIPTURL?>?cmd=product&prd=<?=$products[$i]['id']?>" >
					<img width='120' height='120' src="<?=STATIC_URL?>images/models/<?=$path?>" alt="<?=$products[$i]['category_id']?>:&nbsp;<?=$products[$i]['ru_name']?>" border="0" /><br><br>
					<span class="grey"><?=$products[$i]['ru_name']?>&nbsp;<?=$products[$i]['code']?></span>
				</a>	
				<p><?=$products[$i]['price']?> грн
					<img class="fill_basket" src="<?=STATIC_URL?>images/round_plus.png" pr_id="<?=$products[$i]['id']?>" pr_price="<?=$products[$i]['price']?>" title="Добавить в корзину" alt="Add" border="0" ></p>
			</td>
<?php if (($i != 0 && (($i+1) % 3 == 0)) || $i == $count): ?> 
		</tr>
		<tr>
			<td colspan="3"><br><br></td>
		</tr>
<?php endif;?>
<?php endfor; ?>	
</table>
<script type="text/javascript">
	$(document).ready(function()
		{ 
			$(".fill_basket").attr('style', 'cursor: pointer;').click(function(){
					$.getJSON("<?=SCRIPTURL?>index.php",
					{ 
                        'product_id': 	$(this).attr("pr_id"),
                        'product_price': $(this).attr("pr_price"),
                        'fill_basket': 	'TRUE'
					}, 
					function(data) {
						$('#basket_total_amount span').html(data['total_amount']);
						$('#basket_total_price span').html(data['total_price']);
					});
			});
		});
</script>

